package com.ruoyi.web.controller.nongjt;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.nongjt.domain.PrinterSerialNumber;
import com.ruoyi.nongjt.service.PrinterSerialNumberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/api/printer")
public class PrinterSerialNumberController {

    @Autowired
    private PrinterSerialNumberService printerSerialNumberService;

    @PostMapping("/add")
    @Anonymous
    public ResponseEntity<PrinterSerialNumber> addPrinter(@RequestBody Map<String, String> request) {
        String serialNumber = request.get("serialNumber");
        PrinterSerialNumber printer = printerSerialNumberService.addPrinter(serialNumber);
        return ResponseEntity.ok(printer);
    }

    @GetMapping("/get/{id}")
    @Anonymous
    public ResponseEntity<PrinterSerialNumber> getPrinter(@PathVariable Long id) {
        PrinterSerialNumber printer = printerSerialNumberService.getPrinterById(id);
        return ResponseEntity.ok(printer);
    }
}




